<?php
// 创建client对象
$client = new Swoole\Client(SWOOLE_SOCK_TCP);
if (! $client->connect('127.0.0.1', 9527, 0.5)) {
    die('Connect Failed');
}
echo "connected \n";
if (! $client->send('hello word')) {
    die("send Failed");
}
echo "sended \n";
/* 同步阻塞
    $client->connect()
    $client->send()
    $client->recv()
    会依次阻塞主进程，等待完成才会继续执行下面的代码
*/
$data = $client->recv();
echo "recved \n";
if (!$data) {
    die("recv Failed");
}
echo "rec> {$data}\n";

$client->close();